%%%----------------------------------------------------------------------
%%% File    : errdb_client_sup.erl
%%% Author  : Ery Lee 
%%% Purpose : errdb client supervisor
%%% Created : 28 Aug. 2009
%%% License : http://www.opengoss.com/
%%%
%%% Copyright (C) 2007-2009, www.opengoss.com 
%%%----------------------------------------------------------------------
-module(errdb_client_sup).

-author('ery.lee@gmail.com').

-include("elog.hrl").

-behaviour(supervisor).

%% --------------------------------------------------------------------
%% Include files
%% --------------------------------------------------------------------

%% --------------------------------------------------------------------
%% External exports
%% --------------------------------------------------------------------
-export([start_link/1]).

%% --------------------------------------------------------------------
%% Internal exports
%% --------------------------------------------------------------------
-export([init/1]).

%% --------------------------------------------------------------------
%% Macros
%% --------------------------------------------------------------------
-define(SERVER, ?MODULE).

%% --------------------------------------------------------------------
%% Records
%% --------------------------------------------------------------------

%% ====================================================================
%% External functions
%% ====================================================================
start_link(NumWorkers) ->
  supervisor:start_link({local, ?MODULE}, ?MODULE, NumWorkers).


%% ====================================================================
%% Server functions
%% ====================================================================
%% --------------------------------------------------------------------
%% Func: init/1
%% Returns: {ok,  {SupFlags,  [ChildSpec]}} |
%%          ignore                          |
%%          {error, Reason}
%% --------------------------------------------------------------------
init(NumWorkers) -> 
	?INFO("Errdb client supervisor starting...[ok]", []),
  { 
    ok, 
    {{one_for_one, 3, 10 },
    [begin
         Id = list_to_atom("errdb_client" ++ integer_to_list(I)),
         {Id,
         {errdb_client,
          start_link,
          [Id]},
          permanent,
          brutal_kill,
          worker,
          [errdb_client]}
       end
     || I <- lists:seq(1,NumWorkers)]}}.


